﻿# 设置项目基本信息
set(PROJECT_NAME "xlsx_client")
set(VERSION_ID "5.1.8")

# 定义项目名称和版本信息
project(${PROJECT_NAME} VERSION ${VERSION_ID})

# 初始化源文件列表
set(SOURCES xlsltest.cpp)

# 添加运行程序目标
add_executable(${PROJECT_NAME} ${SOURCES})
# 设置输出目录
set_target_properties(${PROJECT_NAME} PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR}
)

# 设置依赖路径
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(XLSX_INCLUDE_DIR ./openxlsx)
set(LIBXX_LIB .)

# 设置包含头文件目录
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${XLSX_INCLUDE_DIR})
target_link_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_LIB_DIR})
target_link_directories(${PROJECT_NAME} PRIVATE ${OUTPUT_DIR})
target_link_directories(${PROJECT_NAME} PRIVATE ${LIBXX_LIB})
# 平台特定配置
if(MSVC)
    # MSVC 特定的编译选项
    target_compile_options(${PROJECT_NAME} PRIVATE /W3 /wd4996 /wd4819 /wd4828 "/utf-8")

    # Windows 下链接库
    set(PLATFORM_LIBS 
        asset_client${CMAKE_DEBUG_POSTFIX}
        OpenXLSXD.lib
    )

elseif(UNIX AND NOT APPLE)
    # Linux/macOS 特定设置
    set_target_properties(${PROJECT_NAME} PROPERTIES
        VERSION ${VERSION_ID}
        SOVERSION 1
    )

    # Linux 下链接库 + pthread
    set(PLATFORM_LIBS
        pthread
        asset_client${CMAKE_DEBUG_POSTFIX}
    )
else()
    message(WARNING "Unsupported platform.")
endif()

# 链接所有库
target_link_libraries(${PROJECT_NAME} PRIVATE ${PLATFORM_LIBS})

# 设置编译顺序（假设有同名库目标）
add_dependencies(${PROJECT_NAME} asset_client)
